package NO01;

/*
 * 双重锁校验+volatile禁止指令重排序
 */
public class Singleton06 {
	private Singleton06(){}
	//注意volatile关键字，要不然还是非线程安全的
	private static volatile Singleton06 instance = null;
	
	//双重判断
	public static Singleton06 getInstance(){
		if(instance == null){
			synchronized(Singleton06.class){
				if(instance == null){
					instance = new Singleton06();
				}
			}
		}
		return instance;
	}
}
